<?php
namespace app\home\controller;
use PHPUnit\Framework\TestCase;

class Curlrequesttest extends TestCase
{


    public function testCurlRequest()
    {
        
        // 测试正常请求
        $url = 'https://106.ihuyi.com/webservice/sms.php?method=Submit&account=C90800916&password=1b5edacb8f8a4ec7ec7798ab24cd3a06&format=json';
        $post = true;
         $params = [
            'mobile' => 13011539574,
            'content' => "您的验证码是：3587。请不要把验证码泄露给其他人。如非本人操作，可不用理会！",
        ];
        $https = true;

        $result = curl_request($url, $post, $params, $https);

        $this->assertNotNull($result);

        // 测试非 POST 请求
        $post = false;

        $result = curl_request($url, $post, $params, $https);

        $this->assertNotNull($result);

        // 测试非 HTTPS 请求
        $https = false;

        $result = curl_request($url, $post, $params, $https);

        $this->assertNotNull($result);
    }

    public function testSendmsg()
    {
        // 模拟配置信息
        config(['msg.getway' => 'https://example.com/sendmsg']);
        config(['msg.account' => 'test_account']);
        config(['msg.appkey' => 'test_appkey']);

        // 调用函数并获取结果
        $result = sendmsg('13011539574', '测试短信内容');

        // 断言结果
        $this->assertTrue($result);
    }
}
